$(function() {

	// 分龄推荐
	var paramAge0 = {
		"pageNum" : 1,
		"pageSize" : 2,
		"orderByString" : "recommend_star"
	// 如其他要加入排序策略，加参数："orderByString":"recommendStar"
	}
	shouBook(paramAge0, '#book_fenling_show');

	// 人气借阅，根据会员评价星级排序
	var paramAge0 = {
		"pageNum" : 1,
		"pageSize" : 2,
		"orderByString" : "recommend_star"
	}
	shouBook(paramAge0, '#book_renqi_show');
	
	// 新上绘本,根据创建时间
	var paramAge0 = {
		"pageNum" : 1,
		"pageSize" : 2,
		"orderByString" : "create_time"
	}
	shouBook(paramAge0, '#book_zuixin_show');
	
	// 经典导读，根据会员评价星级排序
	var paramAge0 = {
		"pageNum" : 1,
		"pageSize" : 4,
		"orderByString" : "recommend_star"
	}
	shouBook(paramAge0, '#book_jingdian_show');
	
	$("#age0").click(function() {
		shouBook(paramAge0, '#book_fenling_show');
	});
	$("#age1").click(function() {
		var param = {
			"pageNum" : 1,
			"pageSize" : 2,
			"orderByString" : "recommend_star",
			"readMinAge" : 2,
			"readMaxAge" : 4
		};
		shouBook(param, '#book_fenling_show');
	});
	$("#age2").click(function() {
		var param = {
			"pageNum" : 1,
			"pageSize" : 2,
			"orderByString" : "recommend_star",
			"readMinAge" : 5,
			"readMaxAge" : 7
		};
		shouBook(param, '#book_fenling_show');
	});
	$("#age3").click(function() {
		var param = {
			"pageNum" : 1,
			"pageSize" : 2,
			"orderByString" : "recommend_star",
			"readMinAge" : 8,
			"readMaxAge" : 12
		};
		shouBook(param, '#book_fenling_show');
	});
	
	
	
	

	// 显示书籍, Ajax封装，根据不同的参数得到不同的数据
	function shouBook(param, id) {
		$.get({
			url : baseUrl + 'api/book/book/findPage',
			data : param,
			success : function(data) {
				var data = data.data.list;
				$(id).empty();
				var htmlOutput = $.templates("#book_show_tmpl").render(data);
				$(id).html(htmlOutput);
			}
		});
	}


})